package controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;

import model.Palestra;

import org.hibernate.Query;
import org.hibernate.Session;

import connection.HibernateUtil;

public class ListarPalestra implements Logica{
	
	Palestra palestra = new Palestra ();
	@Override
	public void acao(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

		try{
			Session sessao = HibernateUtil.getSession();
			Query listagem;
			listagem = sessao.createQuery("from palestra");
			
			List <Palestra> lista = listagem.list();
			request.setAttribute("lista_palestra", lista);
		
			}catch (Exception e) {
			}
			
			RequestDispatcher view = request.getRequestDispatcher("listarPalestra.jsp");
			view.forward(request, response);
	
	}

}
